<template>
  <div>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column
        :prop="item.prop"
        :label="item.label"
        align="center"
        v-for="(item, index) in stockTableHeard"
        :key="index"
      >
      </el-table-column>
      <!-- 无数据 -->
      <template slot="empty">
        <div class="noData" v-show="tableData.length === 0">
          <!--  v-show="data.length===0" -->
          <img src="@/assets/images/noData.png" />
          <p>暂无数据</p>
        </div>
      </template>
    </el-table>
    <Pagination :total="total" @pagination="handlePage"></Pagination>
  </div>
</template>

<script>
import { stockTableHeard } from "./constant/index.js";
import {buildsFarm} from '@/api/pig-statement/index.js'
export default {
  data() {
    return {
      total: 0,
      tableData: [],
      stockTableHeard,
      data: {
        pageNum:0,
        pageSize:10
      }
    };
  },
  created() {
    this.getTableData()
  },
  methods: {
    async getTableData() {
      let res = await buildsFarm(this.data)
      if (res.code == 200) {
        this.tableData = res.data.list
        this.total = res.data.total
      }
    },
    handlePage(val) {
      this.data.pageNum = val.page;
      this.data.pageSize = val.limit;
      this.getTableData();
    },
  },
};
</script>

<style></style>
